package org.springblade.modules.repair.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.repair.enums.PlanContentFormTypeEnum;

import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @Date 14:07 2022/5/12
 * @Description {
 *   维修故障信息
 * }
 * @Author lsay
 **/
@Data
public class FaultMessageVO {

	private Long id;

	/**
	 * 电梯状态： 1-正常,2-停梯
	 */
	private Integer elevatorStop;

	/**
	 * 问题描述项，dict_key拼接
	 */
	private String problemItem;

	/**
	 * 故障现象其他描述
	 */
	private String problemOtherDesc;

	/**
	 * 故障图片
	 */
	@TableField(typeHandler = JacksonTypeHandler.class)
	private List<HashMap<String,String>> mfImgUrl;

	/**
	 * 描述
	 */
	private String mfDesc;

	/**
	 * 故障现象
	 */
	private List<String> problemItemNames;

	/**
	 * 来源渠道
	 */
	private Integer planFrom;

	/**
	 * 来源渠道描述
	 */
	private String planFromName;

	/**
	 * 报障人名称
	 */
	private String name;

	/**
	 * 联系电话
	 */
	private String phone;

	/**
	 * 部件id集合
	 */
	private String partsIds;

	/**
	 * 部件名称集合
	 */
	private String partsName;

	/**
	 * 配件关联的类目id
	 */
	private Long categoryId;

	/**
	 * 结构类别 0-配件，1-位置
	 */
	private Integer structureType;

	/**
	 * 层站id集合
	 */
	private String floorStandIds;

	/**
	 * 层站名称集合
	 */
	private String floorStandNames;

	/**
	 * 补充故障原因
	 */
	private String faultReasonItem;

	/**
	 * 补充故障原因其他描述
	 */
	private String faultReasonOtherDesc;

	/**
	 * 故障说明
	 */
	private String faultDesc;

	/**
	 * 补充故障图片和视频
	 */
	@TableField(typeHandler = JacksonTypeHandler.class)
	private List<HashMap<String,String>> faultImg;

	/**
	 * 补充故障原因
	 */
	private List<String> faultReasonNames;

	private List<String> faultReasonItemNames;

	private Integer status;

	private List<CheckHistoryRecordVO> malfunctionRecordVO;

	/**
	 * 2024-04-24 新增创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date msgCreateTime;

	/**
	 * 1-无需更换 2-建议更换 3-已更换
	 */
	@TableField(value = "parts_ope")
	private Integer partsOpe;

	/**
	 * 	2024-04-26 新返回创建人id
	 */
	private Long createUserId;

	/**
	 * 2024-04-26 新增创建人姓名
	 */
	private String createUserName;

	private Date updateTime;

	private String updateUserName;

	/**
	 * 处理结果更新时间
	 */
	private Date faultSubmitTime;

	/**
	 * 处理结果更新人名称
	 */
	private String faultSubmitUserName;

	@ApiModelProperty("维修责任")
	private String wxFaultTypeIds;


	@ApiModelProperty("关闭描述")
	private String closeDesc;

	@ApiModelProperty("关闭人")
	private String closeUserName;



	public void setPartsName(String partsName) {
		if(Func.isNotEmpty(partsName)){
			this.partsName = partsName.replace("&amp;&amp;",">");
		}
	}

	public void setFloorStandNames(String floorStandNames) {
		if(Func.isNotEmpty(floorStandNames)){
			this.floorStandNames = floorStandNames.replace("&amp;&amp;",">");
		}
	}

	public void setPlanFrom(Integer planFrom) {
		this.planFrom = planFrom;
		if(Func.isNotEmpty(planFrom)){
			this.planFromName = PlanContentFormTypeEnum.getName(planFrom);
		}
	}

}
